package cn.com.cym.gamezao.entity.single;

import cn.com.cym.gamezao.annotation.Excel;
import cn.com.cym.gamezao.annotation.Sensitive;
import cn.com.cym.gamezao.base.BaseEntity;
import cn.com.cym.gamezao.config.SensitiveStrategy;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.lang.NonNull;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
@Entity
@Accessors(chain = true)
@Table(name ="s_vaccine_reg")
@ApiModel(description = "疫苗登记")
public class VaccineReg extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 8183511932572093870L;

    @Column(length = 60)
    @ApiModelProperty(value = "姓名",dataType = "String",required = true)
    @NonNull
    @Excel(required = true, znName = "姓名")
    @Sensitive(strategy = SensitiveStrategy.USERNAME)
    private String userName;

    @Column(length = 20)
    @ApiModelProperty(value = "证件号",dataType = "String",required = true)
    @NonNull
    @Excel(required = true, znName = "证件号")
    @Sensitive(strategy = SensitiveStrategy.ID_CARD)
    private String certificateCode;

    @Column(length = 10)
    @ApiModelProperty(value = "性别",dataType = "String",required = true)
    @NonNull
    @Excel(required = true,znName = "性别")
    private String sex;

    @ApiModelProperty(value = "年龄",dataType = "Integer",required = true)
    @NonNull
    @Excel(required = true,znName = "年龄")
    private Integer age;

    @Column(length = 50)
    @ApiModelProperty(value = "地区",dataType = "String",required = true)
    @Excel(required = true,znName = "地区")
    @Sensitive(strategy = SensitiveStrategy.ADDRESS)
    private String area;

    @Column(length = 60)
    @ApiModelProperty(value = "疫苗",dataType = "String",required = true)
    @NonNull
    @Excel(required = true,znName = "疫苗")
    private String vaccine;

    @Column(length = 11)
    @Pattern(regexp = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$")
    @ApiModelProperty(value = "联系方式",dataType = "String",required = true)
    @NonNull
    @Excel(required = true,znName = "联系方式")
    @Sensitive(strategy = SensitiveStrategy.PHONE)
    private String telNo;

    @Column(length = 12)
    @ApiModelProperty(value = "状态",dataType = "String",required = true)
    @Excel(required = true,znName = "状态")
    private String regStatus;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "通知时间",dataType = "LocalDateTime",required = true)
    @Excel(required = true,znName = "通知时间")
    private LocalDateTime noticeDateTime;


    /**
     * 验证码，不需要存储在数据库
     */
    @Transient
    private String validCode;
}
